﻿using UnityEngine;
using System.Collections;

/// <summary>
/// Assigns the contents of a text asset to a GUIText instance.
/// </summary>
[ExecuteInEditMode]
[RequireComponent(typeof(GUIText))]
public class ApplyTextAsset : MonoBehaviour {
	
	/// <summary>
	/// The text asset to assign to the GUIText instance.
	/// </summary>
	public TextAsset TextSource;
	
	/// <summary>
	/// GUIText instance intended to be the visual representation of the text asset.
	/// </summary>
	GUIText VisualText;
	
	void OnEnable()
	{
		VisualText = GetComponent<GUIText>();
		
		if (TextSource != null)
			VisualText.text = TextSource.text;
	}
}
